package com.primefaces.www.controllers;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.webflow.controller.HomeController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.nikunj.www.hibernate.service.PersonService;
import com.primefaces.www.dao.ImagesDAO;
import com.primefaces.www.dto.Image;

@Controller
public class PhotoController {
	
	private static final Logger log = LoggerFactory.getLogger(PhotoController.class);
	
	/*@Autowired
	private ImagesDAO imagesDAO;
	*/
	@Autowired
	private PersonService personService;
	

	@RequestMapping(value = "/gallery/{galleryId}", method = RequestMethod.GET)
	public String galleryPageHandler(Locale locale, HttpServletRequest request, Model model,@PathVariable("galleryId") String galleryId) {
		/*List<Image> imageList = imagesDAO.getAllImages("1");
		List<String> images = new ArrayList<String>();
		if(imageList != null){
			for(Image image:imageList){
				images.add(image.getFilepath());
			}
		}
		model.addAttribute("images", imageList);*/
		log.info("Persons:"+personService.getPersons());
		model.addAttribute("persons", personService.getPersons());
		
		return "photos/gallery";
	
	}


		
	
	
}
